#include "Line.h"

Line::Line()
{
    k = -INF;
}

Line::Line(double _k, double _x1, double _y1, double _x2, double _y2)
{
    k      = _k;
    x1     = _x1;
    x2     = _x2;
    y1     = _y1;
    y2     = _y2;
    length = get_length();
}

ostream& operator<<(ostream& output, const Line& l)
{
    output << "begin : " << endl;
    output << "    x : " << l.x1 << " y : " << l.y1 << endl;
    output << "end   : " << endl;
    output << "    x : " << l.x2 << " y : " << l.y2 << endl;
    output << "k : " << l.k << "    length : " << l.length << endl;
    return output;
}

int Line::get_dots() const
{
    double b = y1 - k * x1;
    return (int)((240 - b) / k);
}

double Line::get_length() const
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
